/**
 * 2016年9月8日
 */
package utilities;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

import weka.core.Instances;

/**
 * @author Alex
 *
 */
public class Util {
	protected static File dir = new File("D:\\wekadataset");
	
	public static Instances read(File arff) throws FileNotFoundException, IOException{
		return new Instances(new FileReader(arff));
		
		
	}
	public static Instances readWeatherNominal() throws FileNotFoundException, IOException{
		Instances in = read(new File(dir,"weather.nominal.arff"));
		in.setClassIndex(in.numAttributes()-1);
		return in;
	}
	public static Instances readWeatherNumeric() throws FileNotFoundException, IOException{
		Instances in = read(new File(dir,"weather.numeric.arff"));
		in.setClassIndex(in.numAttributes()-1);
		return in;
	}
	 public static String arrayToTabString(double[] a) {
	        if (a == null)
	            return "null";
	        int iMax = a.length - 1;
	        if (iMax == -1)
	            return "[]";

	        StringBuilder b = new StringBuilder();
	        b.append('[');
	        for (int i = 0; ; i++) {
	            b.append(a[i]);
	            if (i == iMax)
	                return b.append(']').toString();
	            b.append("	");
	        }
	    }
	
}
